<!-- imports -->
<%@page import="www.worq.controller.beans.oficinaBean"%>
<%@page import="java.util.ArrayList"%>
<%@page import="www.worq.controller.beans.personalBean"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page language="java"%>
<%
	if (request.getSession().getAttribute("sesion") == null) {
		request.getSession().setAttribute("error", 1);
		response.sendRedirect("loginErrors");
	} else {
		personalBean usuario = (personalBean) request.getSession()
				.getAttribute("sesion");
		ArrayList<personalBean> catalogo = (ArrayList) request
				.getAttribute("catUsuario");
		ArrayList<oficinaBean> oficinas = (ArrayList) request
				.getAttribute("oficinas");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!--IMPORTANTO ESTILOS-->
<link rel="stylesheet" href="CSS/intranet.css" type="text/css" />
<link rel="stylesheet" href="CSS/intranetAdmon.css" type="text/css" />
<!--IMPORTANTO JS-->
<SCRIPT type=text/javascript src="JS/login.js"></SCRIPT>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>OREQ</title>
</head>
<body>
	<!-- Menu -->
	<div id="menu">
		<div id="navcontainer">
			<ul id="navlist">
				<li id="activo"><img title="Login" alt="MENU"
					onmouseover="document.getElementById('menuRoot').style.display ='block'"
					src="IMG/MENU/menu.png" width="70px" height="60px"></li>
			</ul>
		</div>
	</div>
	<div id="menuRoot" class="menuRoot">
		<div id="navcontainer2">
			<%@ include file='menuRoot.jsp'%>
		</div>
	</div>
	<!-- Body -->
	<div id="contenedor"
		onmouseover="document.getElementById('menuRoot').style.display ='none'">
		<!-- header -->
		<div id="header">
			<p class="bienvenida">
				Bienvidenid@<br>
				<%
					out.println(usuario.getOficina());
						out.println("<br>");
						out.println(usuario.getNombre());
						out.println("<br>");
						out.println(usuario.getRol());
						out.println("<br>");
						out.println(usuario.getEmail());
						out.println("<br>");
						out.println(usuario.getDireccion());
				%>
			</p>
		</div>
		<%
			String mensajeError = (String) request.getAttribute("mensaje");
				if (mensajeError != null) {
		%>
		<h4>
			&nbsp;<%=mensajeError%></h4>
		<%
			request.setAttribute("mensaje", null);
				}
		%>
		<hr>
		<form id="IMPRESION" action='intranetPersonal' method='post' target="_blank">
			<input type='hidden' name='dispatch' value='14' />
		</form>
		<input value="IMPRIMIR" type="button" class="form-enviar"
			onClick="document.getElementById('IMPRESION').submit();">
		<input value="+ PERSONAL" type="button" class="form-enviar"
			onClick="ocultar_mostrar('ALTAUSER'); return false;">
		<div id="ALTAUSER" style="display: none;" class="body">
			<form action="intranetPersonal" method="post"
				onSubmit="return validarPERSONAL(this)" name="altaPersonal">
				<input type='hidden' name='dispatch' value='3' />
				<table id="formularios">
					<tr>
						<td id="coment" colspan="2">+ PERSONAL</td>
					</tr>
					<tr>
						<td align="left">MATRICULA:</td>
						<td align="left">NOMBRE:</td>
					</tr>
					<tr>
						<td align="left"><input name="matricula" type="text"
							class="datos" size="30"
							onfocus="if (this.value == '+ MATRICULA') {this.value=''}"
							value="+ MATRICULA"
							onblur="if(this.value == '') { this.value='+ MATRICULA'}"
							maxlength="18"></td>
						<td align="left"><input name="nombre" type="text"
							class="datos" size="50"
							onfocus="if (this.value == '+ NOMBRE') {this.value=''}"
							value="+ NOMBRE"
							onblur="if(this.value == '') { this.value='+ NOMBRE'}"
							maxlength="200"></td>
					</tr>
					<tr>
						<td align="left">OFICINA:</td>
						<td align="left">ROL:</td>
					</tr>
					<tr>
						<td align="left"><select name="oficina"
							style="width: 300px; color: #000033; font-weight: bold;">
								<%
									for (oficinaBean lista : oficinas) {
											out.println("<option value='" + lista.getNombre() + "'>"
													+ lista.getNombre());
										}
								%>

						</select></td>
						<td align="left"><select name="roles"
							style="width: 300px; color: #000033; font-weight: bold;">
								<option value="ADMINISTRADOR">ADMINISTRADOR</option>
								<option value="RECEPCIONISTA">RECEPCIONISTA</option>
								<option value="ANALISTA">ANALISTA</option>
								<option value="CALIFICADOR">CALIFICADOR</option>
								<option value="REGISTRADOR">REGISTRADOR</option>
						</select></td>
					</tr>
					<tr>
						<td align="left">NOMBRE DE USUARIO:</td>
						<td align="left">CONTRASEÑA:</td>
					</tr>
					<tr>
						<td align="left"><input name="usr_name" type="text"
							class="datos" size="50"
							onfocus="if (this.value == '+ USUARIO') {this.value=''}"
							value="+ USUARIO"
							onblur="if(this.value == '') { this.value='+ USUARIO'}"
							maxlength="50"></td>
						<td align="left"><input name="usr_pass" type="text"
							class="datos" size="50"
							onfocus="if (this.value == '+ CONTRASEÑA') {this.value=''}"
							value="+ CONTRASEÑA"
							onblur="if(this.value == '') { this.value='+ CONTRASEÑA'}"
							maxlength="20"></td>
					</tr>
					<tr>
						<td align="left">EMAIL:</td>
						<td align="left">DIRECCION:</td>
					</tr>
					<tr>
						<td align="left"><input name="email" type="text"
							class="datos" size="50"
							onfocus="if (this.value == 'EMAIL ej.(usuario@dominio.com)') {this.value=''}"
							value="EMAIL ej.(usuario@dominio.com)"
							onblur="if(this.value == '') { this.value='EMAIL ej.(usuario@dominio.com)'}"
							maxlength="90"></td>
						<td align="left"><input name="direccion" type="text"
							class="datos" size="50"
							onfocus="if (this.value == '+ DIRECCION') {this.value=''}"
							value="+ DIRECCION"
							onblur="if(this.value == '') { this.value='+ DIRECCION'}"></td>
					</tr>
					<tr>
						<td colspan="2"><input value="+ AGREGAR" type="submit"
							class="form-enviar"> <input value="- CERRAR"
							type="button" class="form-reset"
							onClick="ocultar_mostrar('ALTAUSER'); return false;"></td>
					</tr>
				</table>
			</form>
		</div>
		<hr>

		<%
			for (personalBean bean2 : catalogo) {
		%>
		<div id="<%=bean2.getId_personal()%>" style="display: none;"
			class="body">
			<form action="intranetPersonal" method="post"
				onSubmit="return validarPERSONAL(this)" name="altaPersonal">
				<input type='hidden' name='dispatch' value='5' /> <input
					type='hidden' name='id_personal'
					value='<%=bean2.getId_personal()%>' />
				<table id="formularios" width="700px">
					<tr>
						<td id="coment" colspan="2">* ACTUALIZAR</td>
					</tr>
					<tr>
						<td align="left">MATRICULA:</td>
						<td align="left">NOMBRE:</td>
					</tr>
					<tr>
						<td align="left"><input name="matricula" type="text"
							class="datos" size="30"
							onfocus="if (this.value == '<%=bean2.getMatricula()%>') {this.value=''}"
							value="<%=bean2.getMatricula()%>"
							onblur="if(this.value == '') { this.value='<%=bean2.getMatricula()%>'}"
							maxlength="18"></td>
						<td align="left"><input name="nombre" type="text"
							class="datos" size="50"
							onfocus="if (this.value == '<%=bean2.getNombre()%>') {this.value=''}"
							value="<%=bean2.getNombre()%>"
							onblur="if(this.value == '') { this.value='<%=bean2.getNombre()%>'}"
							maxlength="200"></td>
					</tr>
					<tr>
						<td align="left">OFICINA:</td>
						<td align="left">ROL:</td>
					</tr>
					<tr>
						<td align="left"><select name="oficina"
							style="width: 300px; color: #000033; font-weight: bold;">
								<option value="<%=bean2.getOficina()%>"><%=bean2.getOficina()%></option>
								<%
									for (oficinaBean lista : oficinas) {
												out.println("<option value='" + lista.getNombre()
														+ "'>" + lista.getNombre());
											}
								%>

						</select></td>
						<td align="left"><select name="roles"
							style="width: 300px; color: #000033; font-weight: bold;">
								<option value="<%=bean2.getRol()%>"><%=bean2.getRol()%></option>
								<option value="ADMINISTRADOR">ADMINISTRADOR</option>
								<option value="RECEPCIONISTA">RECEPCIONISTA</option>
								<option value="ANALISTA">ANALISTA</option>
								<option value="CALIFICADOR">CALIFICADOR</option>
								<option value="REGISTRADOR">REGISTRADOR</option>
						</select></td>
					</tr>
					<tr>
						<td align="left">NOMBRE DE USUARIO:</td>
						<td align="left">CONTRASEÑA:</td>
					</tr>
					<tr>
						<td align="left"><input name="usr_name" type="text"
							class="datos" size="50"
							onfocus="if (this.value == '<%=bean2.getUsr_name()%>') {this.value=''}"
							value="<%=bean2.getUsr_name()%>"
							onblur="if(this.value == '') { this.value='<%=bean2.getUsr_name()%>'}"
							maxlength="50"></td>
						<td align="left"><input name="usr_pass" type="text"
							class="datos" size="50"
							onfocus="if (this.value == '<%=bean2.getUsr_pass()%>') {this.value=''}"
							value="<%=bean2.getUsr_pass()%>"
							onblur="if(this.value == '') { this.value='<%=bean2.getUsr_pass()%>'}"
							maxlength="20"></td>
					</tr>
					<tr>
						<td align="left">EMAIL:</td>
						<td align="left">DIRECCION:</td>
					</tr>
					<tr>
						<td align="left"><input name="email" type="text"
							class="datos" size="50"
							onfocus="if (this.value == '<%=bean2.getEmail()%>') {this.value=''}"
							value="<%=bean2.getEmail()%>"
							onblur="if(this.value == '') { this.value='<%=bean2.getEmail()%>'}"
							maxlength="90"></td>
						<td align="left"><input name="direccion" type="text"
							class="datos" size="50"
							onfocus="if (this.value == '<%=bean2.getDireccion()%>') {this.value=''}"
							value="<%=bean2.getDireccion()%>"
							onblur="if(this.value == '') { this.value='<%=bean2.getDireccion()%>'}"></td>
					</tr>
					<tr>
						<td align="right" colspan="2"><b>CONTRASEÑA DE
								ADMINISTRACION?</b> <input name="secreta" type="password"
							class="secreta" size="30" value="123456" maxlength="20"
							onfocus="this.value=''"
							onblur="if(this.value == '') { this.value='123456'}"></td>
					</tr>
					<tr>
						<td colspan="2"><input value="* ACTUALIZAR" type="submit"
							class="form-enviar"> <input value="REINICIAR"
							type="reset" class="form-reset"></td>
					</tr>
				</table>
			</form>
			<table id="formularios" width="700px">
				<tr>
					<td id="coment" colspan="2">- ELIMINAR</td>
				</tr>
				<tr>
					<td colspan="2">
						<form action="intranetPersonal" method="post"
							onSubmit="return validarDELETE()">
							<input type='hidden' name='dispatch' value='4' /> <input
								type='hidden' name='id_personal'
								value='<%=bean2.getId_personal()%>' /> <b>CONTRASEÑA DE
								ADMINISTRACION?</b> <input name="secreta" type="password"
								class="secreta" size="30" value="123456" maxlength="20"
								onfocus="this.value=''"
								onblur="if(this.value == '') { this.value='123456'}">
								<br><input
								value="- BORRAR" type="submit" class="form-enviar"><input
								value="- CERRAR" type="button" class="form-reset"
								onClick="ocultar_mostrar('<%=bean2.getId_personal()%>');">
						</form>
					</td>
				</tr>
			</table>
		</div>
		<%
			}
		%>
		<table id="customers">
			<tr>
				<th>Oficina</th>
				<th>Nombre</th>
				<th>Rol</th>
				<th>Editar</th>
			</tr>
			<%
				for (personalBean bean : catalogo) {
						out.println("<tr class='alt'>");
						out.println("<td>");
						out.println(bean.getOficina());
						out.println("</td>");
						out.println("<td>");
						out.println(bean.getNombre());
						out.println("</td>");
						out.println("<td>");
						out.println(bean.getRol());
						out.println("</td>");
						out.println("<td align='center'>");
			%>
			<a href="javascript:;"
				onClick="ocultar_mostrar('<%=bean.getId_personal()%>');">EDITAR</a>
			<%
				out.println("</td>");
						out.println("</tr>");
					}
			%>
		</table>
	</div>
</body>
</html>
<%
	}
%>